function getRndStr(le){
		var str='abcdefghijklmnopqrstuvwxyz0123456789';
		var l = parseInt(le)||Math.ceil(Math.random() * 5);
		var ret = '';
		for(var i=0;i<l;i++){
			ret += str.charAt(Math.ceil(Math.random()*(str.length-1)));
		}
		return ret;
	}

function tiaozheng(cust_id,oldcust_class,index,area_attr){
	var cust_end_date=document.getElementById('cust_end_date'+index).value;
	var cust_class=document.getElementById('cust_class_'+index).value;
	
	var agent_product_code ="";
	var product_code ="";
	if(document.getElementById('member_saleprice'+index)!=null){
		var temp=(document.getElementById('member_saleprice'+index).value).split("|");
		product_code=temp[0];
		agent_product_code=temp[1];
		//var obj=document.getElementById('member_saleprice'+index);
		//product_code=obj.options[obj.selectedIndex].text;
		//alert(product_code+",---"+agent_product_code);
	}
	var lhswPwd="";
	if(document.getElementById('lhswPwd_'+index)!=null)
		lhswPwd=document.getElementById('lhswPwd_'+index).value;

	if(cust_end_date==""){
		alert("服务结束时间不能为空");
		return false;
	}
	if(cust_class==""){
		alert("新级别不能为空");
		return false;
	}
	document.bpmForm.cust_id.value=cust_id;
	document.bpmForm.oldcust_class.value=oldcust_class;
	document.bpmForm.lhswPwd.value=lhswPwd;
	document.bpmForm.cust_class.value=cust_class;
	document.bpmForm.cust_end_date.value=cust_end_date;
	document.bpmForm.product_code.value=product_code;
	document.bpmForm.agent_product_code.value=agent_product_code;	
	document.bpmForm.biz_id.value=cust_id;
	document.bpmForm.area_attr.value=area_attr;
	document.bpmForm.submit();

	/**
	document.getElementById('backMessage'+index).innerHTML = '<img src="/program/admin/images/wait.gif"/>正在更新，请稍等...';

	 jQuery.ajax({
			   type: 'POST',
			   url: '/program/admin/member_level/levelService.jsp',
			   data: 'cust_id='+cust_id+'&oldcust_class='+oldcust_class+'&lhswPwd='+lhswPwd+'&cust_class='+cust_class+'&cust_end_date='+cust_end_date,
			   success: function(msg){
					if(msg=="0"||msg==0)
						msg="更新成功";
					else
						msg="更新失败";
					document.getElementById('backMessage'+index).innerHTML = msg;
					document.getElementById('cust_classtxt_'+index).innerHTML=cust_text;
				 }
		});
	*/

 	
}

function checkclass(val,index){
	if(val==""){
		alert("新级别不能为空");
		return false;
	}
	//alert(val);
	if(val=="9"){
		document.getElementById('lhswPwd_'+index).style.display="";
		document.getElementById('lhswPwd_'+index).value=getRndStr(15);
	}
}


function searcher(){

   var start_attr=""; 
  if(document.getElementById("province").value!="")
  {
      start_attr = document.getElementById("province").value+"|"; 
  }

  if(document.getElementById("eparchy_code").value!="")
  {
      start_attr += document.getElementById("eparchy_code").value+"|"; 
  }

  if(document.getElementById("city_code").value!="")
  {
      start_attr += document.getElementById("city_code").value+"|"; 
  }
  
 
  document.getElementById("area_attr").value = start_attr;
  
	document.indexForm.submit();
}

	

function judgeCheck()
{
    var pkid_string = '';
		var listsize = document.getElementById('listsize').value;
		for(var i=0;i<listsize;i++)
		{
				if(document.getElementById('checkone'+i).checked)
				{
					pkid_string += document.getElementById('checkone'+i).value+'|';
				}
		}
    return pkid_string;
}	


function changeTime(){

	var obj = document.getElementById('up_operating').value;
	if( obj == '' || obj.indexOf('-')>-1 || obj.indexOf('c')>-1 || obj.indexOf('d')>-1 ){
		document.getElementById('b_g').style.display = 'none';
	}else{
		document.getElementById('b_g').style.display = 'inline';
	}
}

function operateInfo(val){

	var oper = document.getElementById(val+'_operating').value;
	if(oper == ''){
		alert('请选择操作方式!');
		return false;
	}

	var listsize = document.getElementById('listsize').value;

	var pkid_string = judgeCheck();
	if( pkid_string == '' ){
		alert('请至少选择一个会员进行操作!');
		return false;
	}
	if( oper == '-' ){
		document.getElementById('pkid').value = pkid_string;
		document.indexForm.action = '/doTradeReg.do';
		document.getElementById('bpm_id').value = '5779';
		if(window.confirm('确认删除吗?')){
			document.indexForm.submit();
		}
 	} else if( 'abcd'.indexOf(oper) > -1 ) {
		document.getElementById('pkid').value = pkid_string;
		document.indexForm.action='/doTradeReg.do';
		document.getElementById('bpm_id').value = '8342';
		if(window.confirm('确认提交吗?')){
			document.indexForm.submit();
		}
	} else {
		document.getElementById('pkid').value = pkid_string;
		document.indexForm.action='/doTradeReg.do';
		document.getElementById('bpm_id').value = '2491';
		if(window.confirm('确认提交吗?')){
			document.indexForm.submit();
		}
	}

}

function deleteOneInfo(pkid,bpm_id)
{

	if(window.confirm('确认删除吗？'))
	{
	  window.location.href='/doTradeReg.do?pkid='+pkid+'&bpm_id='+bpm_id;
 	}
}



function setstartProvince(val)
{
	Ts_areaInfo.getAreaClassByUpId('000000000000000',function(data){
		DWRUtil.removeAllOptions(val+'province');
		DWRUtil.addOptions(val+'province',{'':'请选择'});
		DWRUtil.addOptions(val+'province',data);
	})
}

function setCitys(prov,val)
{var provence=prov;
	 Ts_areaInfo.getAreaClassByUpId(provence,function(data){
		DWRUtil.removeAllOptions(val+'eparchy_code');
		DWRUtil.addOptions(val+'eparchy_code',{'':'请选择'});
		DWRUtil.addOptions(val+'eparchy_code',data);
		DWRUtil.removeAllOptions(val+'city_code');
		DWRUtil.addOptions(val+'city_code',{'':'请选择'});
	});
}

function setAreas(city_id,val){
	Ts_areaInfo.getAreaClassByUpId(city_id,function(data){
	 	DWRUtil.removeAllOptions(val+'city_code');
		DWRUtil.addOptions(val+'city_code',{'':'请选择'});
	 	DWRUtil.addOptions(val+'city_code',data);
	});
}